package jonggyuni.basic;

public class Ch04_Q02 {

	public static void main(String[] args) {
		Rectangle r = new Rectangle();
		Rectangle s = new Rectangle(-2,-2,-1,4);
		
		
		r.show();
		s.show();
		
		System.out.println(s.square());
		r.set(-2,2,-1,4);
		r.show();
		System.out.println(r.square());
		
		if(r.equals(s))
			System.out.println("두 사각형은 같습니다.");
		else
			System.out.println("두 사각형은 다릅니다.");

	}//main

}//class


class Rectangle{
	
	int x1,x2,y1,y2;
	int area;
	
	public Rectangle(){	}
	public Rectangle(int x1, int y1, int x2, int y2){
		this.x1 = x1;
		this.x2 = x2;
		this.y1 = y1;
		this.y2 = y2;
	}
	
	void set(int x1, int y1, int x2, int y2){
		this.x1 = x1;
		this.x2 = x2;
		this.y1 = y1;
		this.y2 = y2;
	}
	
	int square(){
		if(x1<0) x1 = -(x1);
		if(x2<0) x2 = -(x2);
		if(y1<0) y1 = -(y1);
		if(y2<0) y2 = -(y2);
		
		area = (x1+x2)*(y1+y2);
		
		return area;	
	}
	
	void show(){
		System.out.println("사각형의 정보 : "+x1+" "+x2+" "+y1+" "+y2+"/사각형의 넓이 : "+ square());
	}
	
	boolean equals(Rectangle r){
		if(r.x1 == x1 && r.x2==x2 && r.y1==y1 && r.y2==y2)
			return true;
		else
			return false;
	}
	
	
}